From 50552a21b196dc7cc53449c8593fee449b1dbfc0 Mon Sep 17 00:00:00 2001 From: oliskoli Date: Tue, 6 Dec 2005 00:41:36 +0000 Subject: [PATCH] New dialog to select anything from any stringlist. --- gpsbabel/win32/gui-2/select.dfm | Bin 0 -> 1450 bytes gpsbabel/win32/gui-2/select.pas | 143 ++++++++++++++++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 gpsbabel/win32/gui-2/select.dfm create mode 100644 gpsbabel/win32/gui-2/select.pas diff --git a/gpsbabel/win32/gui-2/select.dfm b/gpsbabel/win32/gui-2/select.dfm new file mode 100644 index 0000000000000000000000000000000000000000..7544131b3912462d84660a0917a37e0a1aab7574 GIT binary patch literal 1450 zcmb_cO>f#j5M7%O8wf45m*f_yJ@gc{@`aotaG;3-0fDO=+r=!wV(}ug`MO0ys<@%3 zQq>>RLw-pQRn)E$&X4Y?3EVIO`wHuvkz3O`8ZQ*N*5U*8x zoAvt9sKYq(WoGRq>#Q#mUyOt&#)*QFFZ(h$XRZikB)Dbst`5jmMATzZM_zGe+1<&0 zK)E>GaCyK&dBB3xflQ>0oL-*AH6pKa72?~Xg5(S%9s`F^!l z{!sTmx(DTUr|M<(u8P_4`AHD=#D&K$WlnAAD(0VzS{>67OXnM%?G6nm+Z`4KeI2ik zm?O`cyyr%YO4h`K+jcY5OABbxNc-t#*cpfm%SH&jd@HzQe9~gkVdxLcPgyJ<7tWKk z*PTIeD zrV(fRY^<{VdXz1e*7o^f*cX-I|4?@EG-b1gl8s_b3fUHo;09nz?1x`SR$|%Xup*=s zqX&8=K%IXCGq>;c(){~u2C=+KAmI+Bx-x7Y=_~tPOP|!4Oh4Aj+_K8hIuT8BDLRDa zSajIN>j|Q-8<0GLyJaQ2!{!lLC(l4~mxey$y1*;lji(n#>*$Q-(yNwYrNwwUIa@dm;0oK+ zcxf?r_5fE{ae7nSbez(nw77HTh&cchHRjBxu!Goc5eDQ0O388V6c30KdCmp94D(j@S*J4~ZppM2+EhVBxtlox`MJUm_Q=J4IAA lV7a>mQwj4erz;E)JxViumeo3b6OuVT8>yyGO!yZd '') then + begin + i := frmSelect.lbSelect.Items.IndexOf(str); + if (i >= 0) then + frmSelect.lbSelect.ItemIndex := i; + end; + res := frmSelect.ShowModal; + Result := (res = mrOk); + i := frmSelect.lbSelect.ItemIndex; + if Result and (i >= 0) then + Str := frmSelect.lbSelect.Items[i]; + finally + frmSelect.Release; + end; +end; + +function SelectLanguage(const Title: string; const Builtin: TStrings; var Lang: string; const Default: string = ''): Boolean; +var + i: Integer; + s, sx, sy: string; + l: TStrings; + +begin + Result := False; + + if (Default = '') then + Lang := Copy(gnugettext.GetCurrentLanguage, 1, 2); + + l := TStringList.Create; + try + sy := ''; + for i := 0 to Builtin.Count - 1 do + begin + s := Builtin.Strings[i]; + if (s = '') then Continue; + + if (CompareText(s, 'de') = 0) then sx := 'German' else + if (CompareText(s, 'fr') = 0) then sx := 'French' else + if (CompareText(s, 'en') = 0) then sx := 'English' else + sx := '???'; + + sx := Format('%s - %s', [s, sx]); + if (CompareText(s, Lang) = 0) then sy := sx; + + l.Add(sx); + end; + + if SelectFromStringList(Title, l, sy) then + begin + Lang := Copy(sy, 1, 2); + Result := True; + end; + + finally + l.Free; + end; +end; + +{ TfrmSelect } + +procedure TfrmSelect.FormCreate(Sender: TObject); +begin + TranslateComponent(Self); + +// !!! work-arround !!! + btnOK.Caption := dgettext('delphi', 'OK'); + btnCancel.Caption := dgettext('delphi', 'Abort'); +// !!! work-arround !!! +end; + +procedure TfrmSelect.FormShow(Sender: TObject); +var + i: Integer; + s: string; + t: TLabel; +begin + t := TLabel.Create(Self); + try + + t.Caption := ''; + t.Font := lbSelect.Font; + t.ParentFont := lbSelect.ParentFont; + t.Parent := lbSelect.Parent; + + for i := 0 to lbSelect.Items.Count - 1 do + begin + s := Copy(lbSelect.Items[i], 1, 4); + while (t.Canvas.TextWidth(s) < 32) do + s := s + ' '; + s := s + Copy(lbSelect.Items[i], 5, 256); + lbSelect.Items[i] := s; + end; + + finally + t.Free; + end; +end; + +end. -- 2.30.2